﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ATMsystem
{
    public class Account
    {
        private int id;
        private int pswd;
        private int balance = 0;
        private bool isBlocked;
        public int Id
        {
            get => id;
            set => id = value;
        }
        public int Pswd
        {
            get => pswd;
            set => pswd = value;
        }
        public int Balance
        {
            get => balance;
            set => balance = value;
        }
        public bool IsBlocked
        {
            get => isBlocked;
            set => isBlocked = value;
        }
        public Account(int id, int pswd)
        {
            this.id = id;
            this.pswd = pswd;
            
        }
        public Account()
        {
            
        }
        public void saveMoney(int amount)
        {
            Balance += amount;
        }
        public void withdrawMoney(int amount)
        {
            if (Balance >= amount)
            {
                Balance -= amount;
                Random rd = new Random();
                double badRate = rd.NextDouble();
                if (badRate<=0.3) throw new BadCashException("出现坏钞！");
            }
            else return;
        }
        

    }
   
}
